<?php
/**
 * Simple PHP Contact Form
 *
 * This file is part of the Simple PHP Contact Form which is subject to the New
 * BSD License {@see LICENSE} which you would be advised to read before using,
 * modifying or redistributing this software.
 *
 * PHP version 5.2
 *
 * @category  Simple-PHP-Contact-Form
 * @package   Public
 * @author    jah <jah@jahboite.co.uk>
 * @copyright 2010 jah <jah@jahboite.co.uk>
 * @license   New BSD License {@see LICENSE}
 * @version   SVN: $Id$
 * @link      http://code.google.com/p/simple-php-contact-form/
 */


/**
 * Index.  This is the public script through which all requests for the contact
 * application will be routed.
 *
 * @category  Simple-PHP-Contact-Form
 * @package   Public
 * @author    jah <jah@jahboite.co.uk>
 * @copyright 2010 jah <jah@jahboite.co.uk>
 * @license   New BSD License {@see LICENSE}
 * @version   Release: @package_version@
 * @link      http://code.google.com/p/simple-php-contact-form/
 */

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));


// Define path to library directory (not application/library/)
defined('LIBRARY_PATH')
    || define('LIBRARY_PATH', realpath(dirname(__FILE__) . '/../library'));


// Define path to this directory
defined('PUBLIC_ROOT')
    || define(
        'PUBLIC_ROOT',
        (dirname($_SERVER['PHP_SELF']) == '\\' || dirname($_SERVER['PHP_SELF']) == '/'
        ? '/'
        : dirname($_SERVER['PHP_SELF']) . '/')
    );
    


// Define application environment
defined('APPLICATION_ENV')
    || define(
        'APPLICATION_ENV',
        (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production')
    );

    
// Ensure application/library is on include_path
set_include_path(
    implode(
        PATH_SEPARATOR,
        array(
            LIBRARY_PATH,
            realpath(APPLICATION_PATH . '/library'), // TODO is this necessary?
            get_include_path(),
        )
    )
);


/*  ESAPI  */
require_once LIBRARY_PATH . '/ESAPI/src/ESAPI.php';
Global $ESAPI;
$ESAPI = new ESAPI(APPLICATION_PATH . '/configs/ESAPI.xml');
ESAPI::getAuditor('Bootstrap');


/*  Zend_Application  */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
    ->run();
            